
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.common.dto.CommonRepresentationRecordBSearcher;
import com.insigma.business.qrcode.common.dto.CommonRepresentationRecordDO;
import com.insigma.business.qrcode.soldier.dto.CommonRepresentationRecordDTO;
import com.insigma.business.qrcode.soldier.request.CommonRepresentationRecordInsertRequest;
import com.insigma.business.qrcode.soldier.request.CommonRepresentationRecordSearchRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonRepresentationRecordProviderConverter extends AbstractConverter<CommonRepresentationRecordDTO, CommonRepresentationRecordDO> {

    private final static CommonRepresentationRecordProviderConverter commonRepresentationRecordConverter = new CommonRepresentationRecordProviderConverter();

    private CommonRepresentationRecordProviderConverter(){}

    
    public static CommonRepresentationRecordBSearcher convertRequestSO2Searcher(final CommonRepresentationRecordSearchRequest request){
        final CommonRepresentationRecordBSearcher commonRepresentationRecordBSearcher = new CommonRepresentationRecordBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonRepresentationRecordBSearcher);
        return commonRepresentationRecordBSearcher;
    }

    

    
    public static CommonRepresentationRecordDO convertRequestIO2DO(final CommonRepresentationRecordInsertRequest commonRepresentationRecordInsertRequest) {
        final CommonRepresentationRecordDO commonRepresentationRecordDO = new CommonRepresentationRecordDO();
        BeanUtils.copyProperties(commonRepresentationRecordInsertRequest,commonRepresentationRecordDO);
        return commonRepresentationRecordDO;
    }

    
    public static List<CommonRepresentationRecordDTO> convertResponseDOList2DTOList(final List<CommonRepresentationRecordDO> commonRepresentationRecordDOList){
        return commonRepresentationRecordConverter.convertGenericResponseDOList2DTOList(commonRepresentationRecordDOList);
    }

    
    public static CommonRepresentationRecordDTO convertResponseDO2DTO(final CommonRepresentationRecordDO commonRepresentationRecordDO){
        return commonRepresentationRecordConverter.convertGenericResponseDO2DTO(commonRepresentationRecordDO);
    }

    
    @Override
    protected CommonRepresentationRecordDTO doConvertResponseDO2DTO(CommonRepresentationRecordDO commonRepresentationRecordDO) {
        final CommonRepresentationRecordDTO commonRepresentationRecordDTO = new CommonRepresentationRecordDTO();
        try {
            BeanUtils.copyProperties(commonRepresentationRecordDO, commonRepresentationRecordDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonRepresentationRecordDTO;
    }

}
